package com.chenfan.ccp.plug.rpc.service;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public interface FileRemoteService {


    /**
     * 根据文件类型上传
     *
     * @param autoGenerateName 是否自动生成
     * @param ratio            文件压缩率
     * @param files            文件的集合
     * @return 文件的名称，若无则为null
     */
    List<String> uploadByFiles(boolean autoGenerateName,float ratio, float scale, File... files);

    default List<String> uploadByFiles(boolean autoGenerateName, File... files) {
        return uploadByFiles(autoGenerateName, 0f,0f, files);
    }


    default String uploadByStream(InputStream file, float ratio, float scale, String fileName) throws IOException {
        return uploadByImage(ImageIO.read(file), ratio,scale, fileName);
    }

    String uploadByStream(InputStream file, String fileName);


    String uploadByImage(BufferedImage bufferedImage, float ratio, float scale, String fileName) throws IOException;


    String uploadByByte(byte[] file, String fileName);


    boolean deleteByFileNames(String... fileNames);

    File downloadByFile(String fileName);

    byte[] downloadByByte(String fileName);

    /**
     * 注意手动关闭流
     *
     * @param fileName
     * @return
     */
    InputStream downloadByStream(String fileName);
}
